#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "BaseDialog.h"
#include "NetworkQuictunHelper.h"
#include <QWidget>
#include <QMouseEvent>

QT_BEGIN_NAMESPACE
namespace Ui
{
class MainWindow;
}
QT_END_NAMESPACE

class DownloadTool;
class MainWindow : public BaseDialog
{
    Q_OBJECT

  public:
    enum PageType {
        InstallPage = 0,
        ProgressBarPage
    };

    MainWindow(const QString& downloadUrl, const bool& foreFlag, const QString& titleContext,
               const bool& externalNetworkFlag, const QString& quictunPort, const QString& serverAppAddr,
               QWidget* parent = nullptr);
    ~MainWindow();

    void setPageType(PageType pageType);
    void uncompressFile(QString srcPath, QString dstPath);
    bool executeCommand(const QString& command, int maxRetries = 1);
  public Q_SLOTS:
    void onStartInstall();
    void onUpdateProgressBar(qint64 bytesRead = 0, qint64 totalBytes = 0, qreal progress = 0.0);
    void onDownloadFinished();
    void onDownloadFailed();
    void onPlatFormTunnel(CreateTunnelReply);

  private:
    Ui::MainWindow*       ui;
    QString               m_downloadUrl;
    DownloadTool*         m_downloadTool;
    bool                  mForeFlag = false;
    NetworkQuictunHelper* mNetworkQuictunHelper;
    QString               mQuictunPort;
    QString               mServerAppAddr;
    QString               titleContext_;
};
#endif  // MAINWINDOW_H
